"""
File: wework.py
Author: ershixiong
Date: 2023/12/21
describe:

"""

from selenium.webdriver.common.by import By

from hogwarts.Wework.pages.base_page import BasePage
from hogwarts.Wework.utils.utils import save_screen, ele_add_border


class HomePage(BasePage):
    _ADD_USER = (By.XPATH, '//*[text()="添加成员"]')
    _CONTACT = (By.XPATH, '//*[text()="通讯录"]')

    def goto_user_page(self):
        ele = self.find(self._ADD_USER)

        # 元素点击之前添加红框样式,截图
        ele_add_border(self.driver, ele)
        save_screen(self.driver)
        self.find_and_click(self._ADD_USER)

        # 需要局部导入，否则会导致循环导入
        from hogwarts.Wework.pages.user_page import UserPage
        return UserPage(self.driver)

    def goto_contact_page(self):
        self.find_and_click(self._CONTACT)
        from hogwarts.Wework.pages.contact_page import ContactPage
        return ContactPage(self.driver)
